﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace TableControl
{
    [TemplatePart(Name = Table.Container, Type = typeof(Grid))]
    public class Table : ContentControl
    {
        private Grid _container;

        public const string Container = "Container";

        public static readonly DependencyProperty IconSourceProperty = DependencyProperty.Register("IconSource", typeof(ImageSource), typeof(Table), null);
        public static readonly DependencyProperty HeadersProperty = DependencyProperty.Register("Headers", typeof (List<string>), typeof (Table), new PropertyMetadata(default(List<string>)));

        public List<string> Headers
        {
            get { return (List<string>) GetValue(HeadersProperty); }
            set { SetValue(HeadersProperty, value); }
        }

        public ImageSource IconSource
        {
            get { return base.GetValue(IconSourceProperty) as ImageSource; }
            set { base.SetValue(IconSourceProperty, value); }
        }

        public Table()
        {
            DefaultStyleKey = typeof(Table);
            LayoutUpdated += UpdateTable;

            Headers = new List<string>{"Dato", "Test", "Årsag"};
        }

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _container = GetTemplateChild(Container) as Grid;
            var lb = new ListBox();
            lb.ItemsSource = Headers;
            _container.Children.Add(lb);
        }

        private void UpdateTable(object sender, EventArgs e)
        {
            
        }


    }
}
